package com.ogawa.joypal.distributionnetwork.activity

import android.content.Intent
import com.alibaba.android.arouter.facade.annotation.Route
import com.blankj.utilcode.util.ToastUtils
import com.ogawa.base.base.BaseActivity
import com.ogawa.base.utils.AppUtil
import com.ogawa.projectcommon.constants.UrlPathConstant
import com.ogawa.joypal.distributionnetwork.R
import com.ogawa.projectcommon.constants.Constant.*
import com.ogawa.projectcommon.utils.ProjectSpUtils
import kotlinx.android.synthetic.main.activity_start_net_config.*


@Route(path = UrlPathConstant.ACTIVITY_DISTRIBUTIONNETWORK_START_CONNECT)
class StartNetActivity : BaseActivity() {

    override fun getLayoutId(): Int {
        return R.layout.activity_start_net_config
    }

    override fun initView() {
        super.initView()
        setTitle(getString(R.string.start_net_title))
        tv_next.isEnabled = cb_confirm.isChecked
        cb_confirm.setOnCheckedChangeListener { _, b ->
            tv_next.isEnabled = b
        }
        tv_next.setOnClickListener {
            val checkGPSIsOpen = AppUtil.checkGPSIsOpen(this)
            if (!checkGPSIsOpen){
                ToastUtils.showShort(getString(R.string.start_scanwifi_open_gps_tips))
                return@setOnClickListener
            }
            startActivity(Intent(this, NetInputActivity::class.java))
//            finish()
        }



        val projectConfigWifiDeviceBean = ProjectSpUtils.getProjectConfigWifiDeviceBean()
        if (projectConfigWifiDeviceBean.typeCode == TYPECODE_EC_3209G){
            startIv.setImageResource(R.drawable.img_3209e_shoukong)
        }else if (projectConfigWifiDeviceBean.typeCode == TYPECODE_EC_8506E||projectConfigWifiDeviceBean.typeCode == TYPECODE_EC_8506E_JPDC){
            startIv.setImageResource(R.drawable.img_8506e_shoukong)
        }

     }



}
